package com.zhku.onlineshop.Servlet;

import com.zhku.onlineshop.Pojo.Result;
import com.zhku.onlineshop.Pojo.User;
import com.zhku.onlineshop.Service.UserService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@Slf4j
@RestController
@RequestMapping("/User")
public class UserServlet {
    @Autowired
    private UserService userService;

    //新增用户（注册）
    @PostMapping("/Add")
    public Result AddUser(@RequestBody User user){
        if(userService.AddUser(user))
            return Result.success();
        else
            return Result.error("注册失败");
    }
    //修改用户
    @PostMapping("/Upd")
    public  Result UpdUserById(@RequestBody User user){
        if(userService.UpdUserById(user))
            return Result.success();
        else
            return Result.error("修改失败");
    }





}
